import turtle
import math

def draw_pikachu():
    # 设置画布和初始参数
    screen = turtle.Screen()
    screen.title("皮卡丘")
    screen.bgcolor("white")
    screen.setup(width=800, height=600)  # 设置窗口大小，适合VS环境
    
    # 创建绘图对象
    pikachu = turtle.Turtle()
    pikachu.speed(5)  # 适中的速度，便于观察
    pikachu.pensize(2)  # 画笔粗细

    # 函数：绘制圆形
    def draw_circle(radius, color):
        pikachu.fillcolor(color)
        pikachu.begin_fill()
        pikachu.circle(radius)
        pikachu.end_fill()

    # 函数：绘制椭圆
    def draw_oval(radius, stretch):
        pikachu.begin_fill()
        for _ in range(2):
            pikachu.circle(radius, 90)
            pikachu.circle(radius * stretch, 90)
        pikachu.end_fill()

    # 绘制头部
    pikachu.penup()
    pikachu.goto(0, -150)
    pikachu.pendown()
    pikachu.fillcolor("#FEE12B")
    draw_oval(150, 0.8)

    # 绘制左耳朵
    pikachu.penup()
    pikachu.goto(-70, 50)
    pikachu.pendown()
    pikachu.fillcolor("#FEE12B")
    pikachu.begin_fill()
    pikachu.left(60)
    pikachu.forward(100)
    pikachu.right(120)
    pikachu.forward(100)
    pikachu.end_fill()

    # 左耳尖
    pikachu.penup()
    pikachu.goto(-70, 50)
    pikachu.setheading(60)
    pikachu.forward(70)
    pikachu.pendown()
    pikachu.fillcolor("black")
    pikachu.begin_fill()
    pikachu.right(180)
    pikachu.forward(30)
    pikachu.right(120)
    pikachu.forward(30)
    pikachu.end_fill()

    # 绘制右耳朵
    pikachu.penup()
    pikachu.goto(70, 50)
    pikachu.pendown()
    pikachu.fillcolor("#FEE12B")
    pikachu.begin_fill()
    pikachu.right(60)
    pikachu.forward(100)
    pikachu.right(120)
    pikachu.forward(100)
    pikachu.end_fill()

    # 右耳尖
    pikachu.penup()
    pikachu.goto(70, 50)
    pikachu.setheading(120)
    pikachu.forward(70)
    pikachu.pendown()
    pikachu.fillcolor("black")
    pikachu.begin_fill()
    pikachu.right(180)
    pikachu.forward(30)
    pikachu.right(120)
    pikachu.forward(30)
    pikachu.end_fill()

    # 绘制眼睛
    pikachu.penup()
    pikachu.goto(-40, 20)
    pikachu.pendown()
    draw_circle(15, "white")
    pikachu.penup()
    pikachu.goto(-40, 25)
    pikachu.pendown()
    draw_circle(7, "black")

    pikachu.penup()
    pikachu.goto(40, 20)
    pikachu.pendown()
    draw_circle(15, "white")
    pikachu.penup()
    pikachu.goto(40, 25)
    pikachu.pendown()
    draw_circle(7, "black")

    # 绘制腮红
    pikachu.penup()
    pikachu.goto(-70, -20)
    pikachu.pendown()
    pikachu.fillcolor("#FF5252")
    draw_oval(30, 0.5)

    pikachu.penup()
    pikachu.goto(40, -20)
    pikachu.pendown()
    pikachu.fillcolor("#FF5252")
    draw_oval(30, 0.5)

    # 绘制嘴巴
    pikachu.penup()
    pikachu.goto(0, -10)
    pikachu.setheading(-90)
    pikachu.pendown()
    pikachu.stamp()  # 鼻子
    pikachu.penup()
    pikachu.goto(0, -20)
    pikachu.setheading(-90)
    pikachu.pendown()
    pikachu.forward(20)
    pikachu.penup()
    pikachu.goto(0, -20)
    pikachu.setheading(-30)
    pikachu.pendown()
    pikachu.forward(15)
    pikachu.penup()
    pikachu.goto(0, -20)
    pikachu.setheading(-150)
    pikachu.pendown()
    pikachu.forward(15)

    # 隐藏画笔
    pikachu.hideturtle()
    return screen

if __name__ == "__main__":
    # 在VS环境中，这样的结构能更好地控制程序生命周期
    screen = draw_pikachu()
    screen.exitonclick()  # 点击窗口关闭，适合VS环境
    